home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Glyph Substitutions.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  1.6 KB  |  73 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. void GlyphSubstitutions(WindowPtr sampleWindow)
  30.     {
  31.     /* Variables */
  32.     char                *myString = "infinite possibilities";
  33.     gxGlyphcode            layoutGlyphs[50];        /* will be enough... */
  34.     gxGlyphSubstitution    glyphSubst;
  35.     gxPoint                myPoint;
  36.     gxRunControls            gxRunControls;
  37.     gxShape                layout;
  38.     short                len, level = 0;
  39.     gxStyle                myStyle;
  40.     gxViewPort            aViewPort;
  41.     
  42.     /* Initialization */
  43.     
  44.     myPoint.x = ff(30);
  45.     myPoint.y = ff(50);
  46.     
  47.     aViewPort = GXNewWindowViewPort(sampleWindow);
  48.     SetDefaultViewPort(aViewPort);
  49.     
  50.     len = MyStrLen(myString);
  51.     InitializeRunControls(&gxRunControls);
  52.     
  53.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  54.     
  55.     layout = GXNewLayout(
  56.         1, &len, (void *) &myString,
  57.         1, &len, &myStyle,
  58.         1, &len, &level,
  59.         nil, &myPoint);
  60.     GXDrawShape(layout);
  61.     
  62.     GXGetLayoutGlyphs(layout, layoutGlyphs, nil, nil, nil, nil, nil, nil);
  63.     glyphSubst.originalGlyph = layoutGlyphs[0];
  64.     glyphSubst.substituteGlyph = layoutGlyphs[0] + 1;
  65.     GXSetStyleRunGlyphSubstitutions(myStyle, 1, &glyphSubst);
  66.     GXMoveShape(layout, 0, ff(75));
  67.     GXDrawShape(layout);
  68.     
  69.     GXDisposeShape(layout);
  70.     GXDisposeStyle(myStyle);
  71.     GXDisposeViewPort(aViewPort);
  72.     }    /* main */
  73.